package com.atguigu.lease.model.base;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;

@Data
@Schema(description = "实体类的基类")
public class BaseEntity {
    //雪花算法生成唯一id
    @TableId(type = IdType.ASSIGN_ID)
    //jackson将对象转为json字符串时,id属性 转为字符串类型响应
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    //配置自动填充
    @TableField(fill = FieldFill.INSERT)
    //时间日期格式化、时区配置
//    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonIgnore //jackson转json时忽略当前字段
    private Date createTime;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonIgnore //jackson转json时忽略当前字段
    private Date updateTime;
    // 表示生成sql时映射数据库表的列名为is_deleted
    @TableField(value = "is_deleted")
    @JsonIgnore //jackson转json时忽略当前字段
    @TableLogic //逻辑删除
    private Boolean deleted = false;
}
